﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinformText0001
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text;
            var pwd = textBox2.Text;

            var li = users.Where(x => x.Key == uid && x.Value == pwd).Select(x => new { x = x.Key, y = x.Value }).FirstOrDefault();
            if (li != null)
            {
                DialogResult cs = MessageBox.Show("登录成功，是否进入窗体", "恭喜你", MessageBoxButtons.YesNo, MessageBoxIcon.None);
               
                if (cs == DialogResult.Yes)
                {
                    MainForm mainForm = new MainForm();
                    mainForm.Show();
                    
                 


                }
                
            else if (cs == DialogResult.No)
            {
                this.Close();
            }
            }
            else
            {
                MessageBox.Show("登陆失败");
            }
            
          
          

        }

        public static Dictionary<string, string> users = new Dictionary<string, string>();

        private void Form1_Load(object sender, EventArgs e)
        {
            users.Add("admin", "123456");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            RegitForm regitForm = new RegitForm();
            regitForm.Show();
        }
    }
}
